// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) definits fieldsfirst ansi space safe 
// Source File Name:   GizmoSimulation.java

package jones;

import java.util.Iterator;
import java.util.List;
import jones.behavior.GizmoTask;
import jones.behavior.SimplePriorityListArbiter;
import jones.behavior.Task;
import jones.rigid.RigidBody;

// Referenced classes of package jones:
//            SimpleSimulation, Light, SimpleRobot, Wall, 
//            HockeyPuck, Simulation, World

public class GizmoSimulation extends SimpleSimulation
    implements Simulation
{

    private static final int LATENCY = 10;
    private static final int XMIN = 0;
    private static final int YMIN = 0;
    private static final int XMAX = 574;
    private static final int YMAX = 544;
    private static final String NAME = "Gizmo";

    public GizmoSimulation()
    {
        initSimulation();
    }

    public GizmoSimulation(GizmoSimulation simulation)
    {
        for (Iterator i = simulation.lights.iterator(); i.hasNext(); lights.add(((Object) (new Light((Light)i.next())))));
        for (Iterator i = simulation.robots.iterator(); i.hasNext(); robots.add(((Object) (new SimpleRobot((SimpleRobot)i.next(), world)))));
        for (Iterator i = simulation.rigidBodies.iterator(); i.hasNext();)
        {
            RigidBody rigidBody = (RigidBody)i.next();
            if (rigidBody instanceof Wall)
                rigidBodies.add(((Object) (new Wall((Wall)rigidBody))));
            else
            if (rigidBody instanceof HockeyPuck)
                rigidBodies.add(((Object) (new HockeyPuck((HockeyPuck)rigidBody))));
        }

        super.initRigidBodies();
        super.initSimObjects();
        super.initObservables();
        super.initWorld();
        super.initSimulator();
        world.setLatency(simulation.world.getLatency());
        world.setFantasyMode(simulation.world.isFantasyMode());
    }

    public Simulation copySimulation()
    {
        return ((Simulation) (new GizmoSimulation(this)));
    }

    public Simulation createNewSimulation()
    {
        return ((Simulation) (new GizmoSimulation()));
    }

    protected void initLights()
    {
        int SIZE = 60;
        int STEP = 20;
        int BRIGHTNESS = 1000;
        int MARGIN = 20;
        int xmin = 494;
        int xmax = 554;
        int ymin = 242;
        int ymax = ymin + 60;
        for (int i = xmin; i <= xmax; i += 20)
        {
            for (int j = ymin; j <= ymax; j += 20)
                if (i != xmin && i != xmax || j != ymin && j != ymax)
                    lights.add(((Object) (new Light(i, j, 1000D))));

        }

    }

    protected void initRobots()
    {
        SimpleRobot robot = new SimpleRobot(50D, 272D, 0.0D, world);
        Task gizmoTask = ((Task) (new GizmoTask()));
        robot.setBehaviors(gizmoTask.getBehaviors());
        robot.setArbiter(((jones.behavior.Arbiter) (new SimplePriorityListArbiter(((SimpleRobotInterface) (robot)), gizmoTask.getBehaviors()))));
        robots.add(((Object) (robot)));
    }

    protected void initWorld()
    {
        super.initWorld();
        world.setLatency(10);
    }

    public String getName()
    {
        return "Gizmo";
    }
}
